<?php
class H_Model_User extends Zend_Db_Table_Abstract{
    protected $_primary = 'id';
    protected $_name = "";
    public function __construct() {
        parent::__construct();
        $dbconfig = $this->_db->getConfig();
        $this->_name = $dbconfig['prefix'].'user';
    }
    public function updateUser($id,$data)
    {
            $this->fiterData($data);
            $where = $this->_db->quoteInto("id =? ", $id);
            $data['password'] = H_Cryptography_Useracess::encoding($data['password']);
            return $this->update($data, $where);
    }

    public function hasUserPass($user,$pass)
    {
            $select = $this->_db->select();
            $select->from($this->_name,array('user'))
                            ->where("username = ?",$user)
                            ->where("password = ?",H_Cryptography_Useracess::encoding($pass));
            $data = $this->_db->fetchOne($select);
            if (empty($data))
                    return false;
            return true;
    }

    private function fiterData(&$data){
        foreach ($data as $key => $item){
                if (!in_array($key, $this->_getCols())){
                        unset($data[$key]);
                }
        }
    }
}